package jhunter.web.mvc.params;

import java.util.Enumeration;
import java.util.HashMap;

import javax.servlet.ServletRequest;

public class ParameterMap extends HashMap<String, Object> {

	private static final long serialVersionUID = -7064210558184036055L;

	public ParameterMap(ServletRequest request) {
		@SuppressWarnings("rawtypes")
		Enumeration en = request.getParameterNames();
		while (en.hasMoreElements()) {
			String name = (String) en.nextElement();
			String[] values = request.getParameterValues(name);
			Object value = null;
			if (values != null) {
				if (values.length == 1) {
					value = values[0];
				} else {
					value = values;
				}
			}
			super.put(name, value);
		}
	}

}
